package com.yzt.minemodule.activity;

import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.yzt.zhuju.arouter.RouterUser;
import com.yzt.zhuju.base.BaseActivity;
import com.yzt.minemodule.R;
import com.yzt.minemodule.fragment.FriendListFragment;
import com.yzt.plugin_widget.tableBar.SlidingTabLayout;
import com.yzt.plugin_widget.viewPager.ViewPagerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * author : bob
 * date   : 2022/12/12
 * desc   : 好友列表
 */
@Route(path = RouterUser.ACTIVITY_FRIEND_LIST_ACTIVITY)
public class FriendListActivity extends BaseActivity {

    @Autowired
    public int mType;

    @Autowired
    public String mUserId;

    @Override
    public int getLayoutId() {
        return R.layout.activity_friend_list;
    }

    @Override
    public void installViews() {

        SlidingTabLayout mTabLayout = findViewById(R.id.tablayout);
        ViewPager mViewPager = findViewById(R.id.viewPager);

        List<Fragment> fragments = new ArrayList<>();
        List<String> titleList = new ArrayList<>();

        fragments.add(FriendListFragment.newInstance(RouterUser.FriendType.TYPE_FOLLOW, mUserId));
        titleList.add("关注");

        fragments.add(FriendListFragment.newInstance(RouterUser.FriendType.TYPE_FANS, mUserId));
        titleList.add("粉丝");

        fragments.add(FriendListFragment.newInstance(RouterUser.FriendType.TYPE_FRIEND, mUserId));
        titleList.add("好友");

        mViewPager.setAdapter(new ViewPagerAdapter(getSupportFragmentManager(), fragments, titleList));
        mViewPager.setOffscreenPageLimit(titleList.size());
        mTabLayout.setViewPager(mViewPager);

        mViewPager.setCurrentItem(mType);


        findViewById(R.id.left_layout).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        if (view.getId() == R.id.left_layout) {
            finish();
        }
    }
}
